# 指定这个子目录的CMakeLists.txt处理源文件
set(PLAYER_SRC player/AudioPlayer.cpp)

# 指定生成目标
add_library(LJNAudioPlayer STATIC ${PLAYER_SRC})

if(ANDROID)
    list(APPEND LJN_AUDIO_PLAYER_LINKED_LIBS
        PRIVATE
            log
            OpenSLES
    )
elseif(IOS)
    list(APPEND LJN_AUDIO_PLAYER_LINKED_LIBS
        PRIVATE
            "-framework Accelerate"
            "-framework CoreFoundation"
            "-framework AudioToolbox"
            "-framework CoreAudio"
            "-framework AVFoundation"
    )
endif()

if(ANDROID)
    include_directories(${LJN_AUDIO_PLAYER_DIR}/lib/fmod/android/inc)
    link_directories(${LJN_AUDIO_PLAYER_DIR}/lib/fmod/android/lib/arm64-v8a)
    list(APPEND LJN_AUDIO_PLAYER_LINKED_LIBS
        PRIVATE
            libfmod.so 
            libfmodL.so
    )
elseif(IOS)
    message(SRC Include: ${LJN_AUDIO_PLAYER_DIR}/lib/fmod/ios/inc)
    include_directories(${LJN_AUDIO_PLAYER_DIR}/lib/fmod/ios/inc)
    list(APPEND LJN_AUDIO_PLAYER_LINKED_LIBS
        PRIVATE
            ${LJN_AUDIO_PLAYER_DIR}/lib/fmod/ios/lib/libfmod_iphoneos.a 
            ${LJN_AUDIO_PLAYER_DIR}/lib/fmod/ios/lib/libfmodL_iphoneos.a
    )
elseif(APPLE)
    message(STATUS "SRC Include: ${LJN_AUDIO_PLAYER_DIR}/lib/fmod/mac/inc")
    include_directories(${LJN_AUDIO_PLAYER_DIR}/lib/fmod/mac/inc)
    link_directories(${LJN_AUDIO_PLAYER_DIR}/lib/fmod/mac/lib/${CMAKE_OSX_ARCHITECTURES})
    list(APPEND LJN_AUDIO_PLAYER_LINKED_LIBS
        PRIVATE
            ${LJN_AUDIO_PLAYER_DIR}/lib/fmod/mac/lib/libfmod.dylib 
            ${LJN_AUDIO_PLAYER_DIR}/lib/fmod/mac/lib/libfmodL.dylib
    )
endif()

target_link_libraries(LJNAudioPlayer PRIVATE ${LJN_AUDIO_PLAYER_LINKED_LIBS})
